Repository navigation
feat: publish a package template from its producers' releases - #4
Merged
Merged
Conversation
scripts/publish-template.py reads the template composition that a declaration repository's MAINTENANCE.md declares, clones each producer's highest vMAJOR.MINOR.PATCH release, runs its generators into empty directories and writes the declared template paths. When files change, it commits them signed on one branch, opens one pull request listing each release, and requests auto-merge where the template allows it. The unit suite runs it against local producer, template and declaration repositories. No workflow calls it yet; a maintainer runs it after each producer release until an App credential can open pull requests.
This was referenced Oct 24, 2026
The publisher requires origin to name the declared template on GitHub and to push where it fetches, rejects Git metadata paths in any letter case, nested declared files and file ancestors before writing, and stops before writing when the publication branch already exists. A failed push, pull request or auto-merge request reports the command that completes it.
The publisher checks every effective fetch and push URL of the template's origin, after Git's URL rewriting, against the declared repository on GitHub, and rejects declared paths that collide or nest when letter case is ignored. A failed push, pull request or auto-merge request now asks for the same command again: the rerun resumes from the publication branch in the checkout or on origin when that branch builds on the current default head and holds the current releases' output, keeping the pull request's description.
A publishing run stops before writing when its publication branch exists. A failed push or pull request prints the git -C commands that delete the branch, after which the same command publishes again from the default branch head, so the script only ever pushes the commit it just created. A failed auto-merge request leaves the open pull request.
The recovery after a failed push or pull request is built from where the failure happened instead of another ls-remote, so an outage that fails the push still prints the original error and the commands that delete the publication branch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
scripts/publish-template.pypublishes a template repository's generated files from their producers' releases, as declared by atemplate-compositionJSON block in the declaration repository'sMAINTENANCE.md(swift-library/.github#45 adds the block for swift-package-template). For each producer it clones the highestvMAJOR.MINOR.PATCHtag, runs that producer's generators into empty directories, requires the generated files to be exactly the declared ones, and writes only the declared template paths. When anything changed, it commits signed onchore/publish-<digest>, pushes, opens one pull request listing each producer's release, commit and changed files, and requests a squash auto-merge of that head when the template allows auto-merge.--write-onlystops after writing the files.The README's new "Package template publication" section documents the declaration format and the run. Tests use local producer, template and declaration repositories, real SSH-signed commits and a stub
gh.Decisions
vMAJOR.MINOR.PATCHtag without a pre-release suffix: none of these repositories publishes GitHub Releases, only tags.Package.swift,Sources,Tests,VERSIONandCHANGELOG.mdare not declared.git -C <template>commands that delete the branch, and the same command then publishes again from the default branch head, so the script only ever pushes the commit it just created. A failed auto-merge request leaves the open pull request to merge by hand.allow_auto_merge: false, so a run leaves the pull request for a manual merge after the required checks pass. Enabling it is a settings change for the owner.Validation
python3 -m unittest discover -s tests: 142 tests pass, 22 of them for the publisher. The tests servegit@github.com:URLs from local bare repositories through a stubssh, so the GitHub-only origin check runs as in production. After each injected failure, the tests run the printed commands from outside the template checkout and publish again.actionlintpasses..GITcase variants passed, nested or file-ancestor destinations passed, and interrupted runs could not be completed..GITfix and raised three more: URL rewriting could redirect origin, case-variant destinations still collided, and the recovery commands were directory-dependent and lost the PR description.masterwith showxu/skillsv0.1.2: both producers reportcurrent, so the composition reproduces the template's current files;AGENTS.mdandDocumentation/Reference/Release.md, byte for byte as in docs: re-export cited-source and result-reuse wording swift-package-template#16, and nothing else.Release-relevant
swift-library/skills' latest tag,
v0.1.0, predatesexport_profile.py, so the first real publication needs a skills release that contains it. showxu/skillsv0.1.2already reproduces the template's logo byte for byte.